<?php
	session_start();	
?>

<?php
	if( $_SESSION["admin"] != "" )
	{
?>
<a href="index.php?com=partner"><b>List partner</b></a> | <a href="index.php?com=partner&func=add"><b>Add partner</b></a>
<?php
	include_once("process/partner.php");	
	$partner = new partner();
	
	if( $_GET["com"] == "partner" && $_GET["func"] == "update" && isset($_GET["id"]))
	{
		$row = $partner->GetOnePartner($_GET['id']);	
	}elseif( isset($_POST['btnUpdate']) )
	{	
			$Title = stripcslashes($_POST["Title"]);
    		$SourceCode=stripcslashes($_POST["SourceCode"]);
    		$Description=stripcslashes($_POST["Description"]);
            $HitNumber=stripcslashes($_POST["HitNumber"]);
            $AddToCart=stripcslashes($_POST["AddToCart"]);
            $Ordered=stripcslashes($_POST["Ordered"]);
            $ActiveYN=stripcslashes($_POST["ActiveYN"]);
            $id = stripcslashes($_POST["PartnerID"]);
			$partner->UpdatePartner($Title, $SourceCode, $Description, $HitNumber, $AddToCart,
            $Ordered, $ActiveYN, $id);
			echo '<meta http-equiv="Refresh" content="0;URL=index.php?com=partner" />';
	}
	else
	{
		echo '<meta http-equiv="Refresh" content="0;URL=index.php?com=partner" />';
	}	
	
?>
<form action="index.php?com=partner&func=update" method="post" id="contactform">
	<table width="630px" style="font-weight:bold; font-size:10pt;" border="0">
		<tr>
			<td align="center" colspan="4" height="50"><b style="font-size:12pt; color:Blue;">Update partner</b></td>
		</tr>
		<tr height="26">
			<td align="right" width="120px">Title :&nbsp;&nbsp;
				<input type="hidden" name="PartnerID" id="PartnerID" value="<?php echo $row['PartnerID'] ?>" />
			</td>
			<td width="140px"><input type="text" class="validate[required]" name="Title" id="Title" value="<?php echo $row['Title']; ?>" style="width: 120px;" /><font style="color: red;"> *</font>
				<input type="hidden" name="PartnerID" id="PartnerID" value="<?php echo $row['PartnerID'] ?>" />
			</td>
        </tr>
        <tr>
			<td align="right" width="120px">Source Code :&nbsp;&nbsp;</td>
			<td><input type="text" name="SourceCode" id="SourceCode" value="<?php echo $row['SourceCode']; ?>" style="width: 120px;" /><font style="color: red;"> *</font></td>
		</tr>  	    
        <tr>
			<td align="right" width="120px">Description :&nbsp;&nbsp;</td>
			<td><textarea rows="7" name="Description" id="Description" cols="95"><?php echo $row['Description']; ?></textarea></td>" style="width: 120px;" /><font style="color: red;"> *</font></td>
		</tr> 
        <tr>
			<td align="right" width="120px">Hit Number :&nbsp;&nbsp;</td>
			<td><input type="text" name="HitNumber" id="HitNumber" value="<?php echo $row['HitNumber']; ?>" style="width: 120px;" /><font style="color: red;"> *</font></td>
		</tr>  	    
        <tr>
			<td align="right" width="120px">Add To Cart :&nbsp;&nbsp;</td>
			<td><input type="text" name="AddToCart" id="AddToCart" value="<?php echo $row['AddToCart']; ?>" style="width: 120px;" /><font style="color: red;"> *</font></td>
		</tr>
        <tr>
			<td align="right" width="120px">Ordered :&nbsp;&nbsp;</td>
			<td><input type="text" name="Ordered" id="Ordered" value="<?php echo $row['Ordered']; ?>" style="width: 120px;" /><font style="color: red;"> *</font></td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">ActiveYN :&nbsp;&nbsp;</td>
			<td>
				<select size="1" name="ActiveYN">
        			 <?php
                if($row['ActiveYN'] == 'Yes')
                {
            ?>
                <option value="Yes">Yes</option>
                <option value="No">No</option>
            <?php
                }
                else
                {
            ?>
                <option value="No">No</option>
                <option value="Yes">Yes</option>
            <?php
                }
            ?>
			 </select>
			</td>
		</tr>
		<tr>
			<td></td>
			<td colspan="3" height="40">
				<input type="submit" name="btnUpdate" id="btnUpdate" value="Update" />
				<input type="reset" value="Reset" />
			</td>
		</tr>
    </table>
</form><br><br>
<i>Please fill in these fields (<font style="color: red;">*</font>)</i>
<?php
    }
   else
	{
		echo "<meta http-equiv='refresh' content='0; url=login.php' />";
	}
?>